package com.example.kotlinExample.enum


/**
 *
 *
 * @author liliang
 */
enum class Gender(var code: Int, var gender: String) {

    MAN(1, "男"), WOMAN( 2, "女");

    companion object {
        fun getCodeByGender(gender: String): Int {
            for (value in values()) {
                if (gender == value.gender) {
                    return value.code
                }
            }
            return 0
        }
    }

}

fun main() {
    println(Gender.getCodeByGender("女"))
}